package net.csdn.business.common.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.csdn.business.common.constant.CommonConstants;
import net.csdn.business.common.domain.PageDto;
import net.csdn.business.common.domain.issue.IssueExt;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author likun
 * @date 2022/6/14 14:22
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class IssueVo implements Serializable {
    /**
     * 跳转（移动的issue需要跳转到新的地址）
     */
    private Boolean direct;

    private String url;

    /**
     * issue#object_id
     */
    private String issueId;
    private String uid;
    private Integer userType;
    private UserVo authorInfo;
    private Long projectId;
    private Integer serialNumber;
    private Integer privacy;
    private Integer status;
    private Integer statusReason;
    private Integer lock;
    private String assignUser;
    private UserVo assignUserInfo;
    private String title;
    @JsonFormat(pattern = CommonConstants.DEFAULT_PATTERN, timezone = CommonConstants.DEFAULT_TIMEZONE)
    private Date createdDate;
    @JsonFormat(pattern = CommonConstants.DEFAULT_PATTERN, timezone = CommonConstants.DEFAULT_TIMEZONE)
    private Date updatedDate;
    @JsonFormat(pattern = CommonConstants.DEFAULT_PATTERN, timezone = CommonConstants.DEFAULT_TIMEZONE)
    private Date closedDate;

    private String bodyId;

    private String body;

    /**
     * 创建issue的第一条评论
     */
    private CommentVo commentVo;

    /**
     * 详情评论列表
     */
    private PageDto<CommentVo> comments;

    /**
     * 统计信息 key=resource_stat#key
     */
    private Map<String, StatVo> stats;

    /**
     * 代码库完整路径（含完整组路径）
     */
    private String pathWithNamespace;
    /**
     * 代码库完整名称（含完整组名称）
     */
    private String nameWithNamespace;

    /**
     * 审核状态 {@link net.csdn.business.common.enums.AuditEnum.AuditStatusEnum}
     */
    private Integer auditStatus;

    /**
     * 是否设置label
     */
    private Integer label;

    private List<LabelVo> labels;

    private Integer sort;

    private Integer pin;

    /**
     * issue优先级 {@link net.csdn.business.common.enums.IssueEnum.PriorityEnum}
     */
    private Integer priority=0;

    private String milepostId;

    /**
     * 里程碑
     */
    private MilepostVo milepost;

    private IssueExt ext;

    public IssueVo(String issueId, String url, Long projectId, Integer serialNumber, String pathWithNamespace) {
        this.direct = true;
        this.issueId = issueId;
        this.url = url;
        this.projectId = projectId;
        this.serialNumber = serialNumber;
        this.pathWithNamespace = pathWithNamespace;
    }
}